package com.jt.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.jt.pojo.ItemCat;
import com.jt.service.ItemCatService;
import com.jt.vo.SysResult;
import lombok.experimental.Accessors;
import org.apache.ibatis.annotations.Delete;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@Controller
@RequestMapping("itemCat")
@CrossOrigin
public class ItemCatController {
    @Autowired
    private ItemCatService itemCatService ;
@GetMapping("findItemCatList/{level}")
 public SysResult findItemCatList(@PathVariable  Integer level){
        List<ItemCat> list = itemCatService.findItemCatList(level);
        return SysResult.success(list);
    }
/*实现商品新增*/
    /*saveItemCat*/
    @PostMapping("saveItemCat")
    public SysResult saveItemCat(@RequestBody ItemCat itemCat){
        itemCatService.saveItemCat(itemCat);
        return SysResult.success();
    }
    @DeleteMapping("/deleteItemCat")
    public SysResult delete(ItemCat itemCat){
        itemCatService. delete(itemCat);
        return SysResult.success();
    }
    @PutMapping("status/{id}/{status}")
    public SysResult updataSatus(ItemCat itemCat){{

        itemCatService.updataSatus(itemCat);
        return  SysResult.success();
    }}
    @PutMapping("updateItemCat")
    public SysResult updateItemCat(@RequestBody ItemCat itemCat){
        itemCatService.updateItemCat(itemCat);
        return SysResult.success();
    }
}

